package homework.homework_7.Enter;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @author 朱
 * @date 201904019:00
 */
public class UserTest {
    static Scanner scannerString=new Scanner(System.in);
    static Scanner scannerInt=new Scanner(System.in);
    static UserDaoImp userDaoImp=new UserDaoImp();
    public static void main(String[] args) {
       while (true){
           System.out.println("——欢迎光临——");
           System.out.println("——1.注册——");
           System.out.println("——2.登录——");
           System.out.println("——3.搜索——");
           System.out.println("——4.退出——");
           int chese=scannerInt.nextInt();
           switch (chese){
               case 1:
                   regist();
                   break;
               case 2:
                   login();
                   break;
               case 3:
                   serch();
                   break;
               case 4:
                   System.out.println("欢迎下次光临");
                   System.exit(0);
               default:
                   System.out.println("输入错误");
                   break;
           }
       }


    }

    private static void regist() {
        System.out.println("----注册界面----");
        System.out.println("请输入用户名：");
        String user=scannerString.nextLine();
        System.out.println("请输入密码：");
        String password=scannerString.nextLine();
        System.out.println("请输入邮箱：");
        String email=scannerString.nextLine();
        User user1=new User(user,password,email);
        userDaoImp.regist(user1);
    }

    private static void login() {
        System.out.println("----登陆界面----");
        System.out.println("请输入用户名：");
        String user=scannerString.nextLine();
        System.out.println("请输入密码：");
        String password=scannerString.nextLine();
        userDaoImp.login(user,password);
    }

    private static void serch() {
        System.out.println("----搜索界面----");
        System.out.println("请输入用户名：");
        String user=scannerString.nextLine();
        userDaoImp.search(user);

    }
}
